Making a Mission

This document is about the implementation details of making a mission for Bridge Commander. You should probably already have a good idea of what you want your mission to be like, and it also wouldn't hurt to take a glance at some of the mission scripts in the game (E2M6 is recommended as a fairly straightforward example). It is also recommended that you read the basics page as well as the API basics page before beginning.

Missions are composed of a lot of Python functions. Some of them are called by the game, others you set up to be called by the mission itself.


Initialization and Termination

Each mission is required to have two functions, called Initialize(), and Terminate(). The C++ object that represents the mission is passed in. These two functions are the barest minimum necessary to constitute a "mission" -- you'll want lots more, to do mission-specific things, but this is the starting point for building a mission.

def Initialize(pMission):
	# In Initialize(), you set up everything you need for the mission.

	# Create the regions (space sets) for this mission
	CreateRegions()
	
	# Create bridge sets we need.
	CreateSets()
	
	# Create the starting objects.
	CreateStartingObjects(pMission)
	
	# Setup more mission-specific events.
	SetupEventHandlers()

def Terminate(pMission):
	# Do whatever shutdown stuff might be necessary.
	.
	.
	.
	return
The CreateRegions(), CreateSets(), CreateStartingObjects(), and SetupEventHandlers() functions are user-created functions that set up various elements of the mission. These "kick off" the mission.


Creating sets

Sets contain game objects, and you must have some in order to have any sort of mission. You'll typically create some space sets, where ships will travel and fight, and then some other sets in which you'll place animated characters.

Creating space sets is fairly easy, if you use the pre-existing sets that come with the game. You can just use the MissionLib function SetupSpaceSet() with the package name of the set. If you have a placement file for this set (for this mission), you can then load it afterwards.

# Creates and sets up the space set for Biranu 1.
pBiranu1Set = MissionLib.SetupSpaceSet("Systems.Biranu.Biranu1")

# Load the mission-specific placement file for this set.
import E2M6_Biranu1_P
E2M6_Biranu1_P.LoadPlacements(pBiranu1Set.GetName())
You can create bridge sets (for animated characters) easily, also, using another MissionLib function, SetupBridgeSet(). You specify the set name (used to refer to the set in the set manager), and the model to use, along with a camera position for the set.
	pStarbaseSet	= MissionLib.SetupBridgeSet("StarbaseSet", "data/Models/Sets/StarbaseControl/starbasecontrolRM.nif", -30, 65, -1.55)


Creating Objects

Once you've created some sets, you can populate them with objects. For example, you can create the player's ship, some other ships, and characters on other bridge sets. The player's bridge is set up specially, though, so you don't really need to do much to make it.

Creating the player

To create the player's ship, use the MissionLib function CreatePlayerShip().

MissionLib.CreatePlayerShip(sShipClass, pSet, pcName, sWaypoint, bUnloadShip)

Creating other ships

To create other ships, use the function in the loadspacehelper module, called CreateShip().

pGalor1 = loadspacehelper.CreateShip("Galor", pBiranu1Set, "Galor 1", "Galor1Start")


Created on ... February 04, 2002